package com.aqiang.day0528_shop.user.presenter

import com.aqiang.day0528_shop.user.contract.UserContract
import com.aqiang.day0528_shop.user.model.LoginModel

class LoginPresenter(var v:UserContract.LoginView) : UserContract.LoginPresenter(v) {
    override fun authLogin() {
        if (mView.get() != null && mView != null){
            val responseEntity = mModel.login(mView.get()!!.getUser(), mView.get()!!.getAuth())
            mView.get()!!.success(responseEntity)
        }
    }

    override fun auth() {
        if (mView.get() != null && mView != null){
            val auth = mModel.auth()
            mView.get()!!.successAuth(auth)
        }
    }

    override fun login() {
        if (mView.get() != null && mView != null){
            val responseEntity = mModel.login(mView.get()!!.getUser(), mView.get()!!.getPwd())
            mView.get()!!.success(responseEntity)
        }
    }

    override fun initModel(): UserContract.LoginModel {
        return LoginModel()
    }
}